﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using TomNet.App.Core.Contracts;
using TomNet.App.Model.DB;
using TomNet.App.Model.DTO;
using TomNet.AspNetCore.Data;
using TomNet.SqlSugarCore.Entity;
using TomNet.Security.Claims;
using System.Security.Claims;

namespace TomNet.App.Web.Controllers
{
    [Authorize]
    [Description("收益日报管理")]
    public class DailyController : Controller
    {
        private readonly IProductContract _productContract;        
        private readonly IUnitOfWork _unitOfWork;
        public DailyController(IProductContract productContract,            
            IUnitOfWork unitOfWork)
        {
            _productContract = productContract; 
            _unitOfWork = unitOfWork;
        }
        [Description("收益日报列表")]
        [HttpGet]
        public IActionResult DailyList()
        {
            return View();
        }
        [Description("收益日报列表")]
        [HttpPost]
        public IActionResult DailyList(int page = 1, int limit = 20)
        {
            var entry = _productContract.Entities.AsQueryable();
            //entry.WhereIF(!string.IsNullOrEmpty(name), m => m..Contains(name));
            entry.OrderBy(m => m.Id, OrderByType.Desc);
            int total = 0;
            var list = entry.ToPageList(page, limit, ref total);
            var result = new LayuiPageResult<Product>
            {
                Code = 0,
                Msg = "Success",
                Count = total,
                Data = list.ToArray()
            };
            return Json(result);
        }        
    }
}